package it.tukano.swingdeco.text;

import java.awt.Color;
import java.awt.Font;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;

/**
 * A simple attribute set extension
 * @author pgi
 */
public class SimpleAttributeSetExt extends SimpleAttributeSet {

    private static final long serialVersionUID = 0;

    /**
     * Instance initializer
     */
    public SimpleAttributeSetExt() {
    }

    /**
     * Set the font
     * @param font the font to set
     * @return this
     */
    public SimpleAttributeSetExt setFont(Font font) {
        StyleConstants.setFontFamily(this, font.getFamily());
        StyleConstants.setBold(this, font.isBold());
        StyleConstants.setFontSize(this, font.getSize());
        StyleConstants.setItalic(this, font.isItalic());
        return this;
    }

    /**
     * Set the font color
     * @param color the color to set
     * @return this
     */
    public SimpleAttributeSetExt setForeground(Color color) {
        StyleConstants.setForeground(this, color);
        return this;
    }
}
